<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:demo="http://omnifaces.org/showcase"
>
	<ui:define name="description">
		<p>
			The <code>&lt;o:importFunctions&gt;</code> allows the developer to have access to all functions of the given
			fully qualified name of a type in the EL scope using the usual EL functions syntax without the need to register them
			in <code>.taglib.xml</code> file. The functions are those <code>public static</code> methods with a
			<strong>non</strong>-<code>void</code> return type. For example:
		</p>
		<pre><code>
&lt;o:importFunctions type="java.lang.Math" var="m" /&gt;
&lt;o:importFunctions type="org.omnifaces.util.Faces" /&gt;
...
\#{m:abs(-10)}
\#{m:max(bean.number1, bean.number2)}
...
&lt;base href="\#{Faces:getRequestBaseURL()}" /&gt;
		</code></pre>
		<p>
			The functions prefix becomes by default the simple name of the type. You can override this by explicitly
			specifying the <code>var</code> attribute. If there are multiple function methods with exactly the same name, then
			the one with the least amount of parameters will be used. If there are multiple function methods with exactly the
			same name and amount of parameters, then the choice is unspecified (technically, JVM-dependent) and should not be
			relied upon. So if you absolutely need to differentiate functions in such case, give them each a different name.</p>
			<p>Note that the colon <code>:</code> operator to invoke the method is as required by EL functions spec. It's by design
			not easily possible to change it to the period <code>.</code> operator. Also note that in case of the 
			<code>org.omnifaces.util.Faces</code> example it's considered poor practice if the same functionality is already 
			available through the implicit EL variables <code>\#{facesContext}</code>, <code>\#{view}</code>, <code>\#{request}</code>,
			etc such as <code>\#{request.contextPath}</code> which should be preferred over <code>\#{Faces:getRequestContextPath()}</code>.
		</p>
		<p>
			The resolved functions are by reference stored in the cache to improve retrieving performance.
		</p>
	</ui:define>

	<ui:define name="demo">
		<o:importFunctions type="java.lang.Math" var="m" />

		<h3>The functions of <code>java.lang.Math</code></h3>
		<ul>
			<li><code>abs(-10)</code>: #{m:abs(-10)}</li>
			<li><code>min(-10, 20)</code>: #{m:min(-10, 20)}</li>
			<li><code>max(-10, 20)</code>: #{m:max(-10, 20)}</li>
			<li><code>floor(12.34)</code>: #{m:floor(12.34)}</li>
			<li><code>ceil(12.34)</code>: #{m:ceil(12.34)}</li>
			<li><code>random()</code>: #{m:random()}</li>
		</ul>
	</ui:define>
</ui:composition>